<script setup>
    import { useRoute, useRouter } from 'vue-router'
    import AddressCard from '@/components/address/AddressCard.vue'

    const router = useRouter()
    const route = useRoute()    

    // 返回
    const clickMy = ()=>{
        if (route.query.address) {
            // 返回商店或购物车
            router.push({
                path:'/orderCV',
                query:{
                    address:route.query.address,
                    shopName:route.query.shopName
                }
            })
        }else{
            // 返回我的页面
            router.push({
                path:'/my',
            })

        }
    }


    // 前往创建地址页面
    const clickCreate = ()=>{
        router.push({
            path:'/createaddress',
            query:{
                    address:route.query.address,
                    shopName:route.query.shopName
                }
        })
    }
</script>

<template>
  <div class="address_list">
        <div class="address_list_header">
            <span class="iconfont title_back" @click="clickMy">&#xe697;</span>
            <div class="title_text">收货地址</div>
            <div class="create" @click="clickCreate">新建</div>
       </div>
        <div class="address_list_content">
            <div class="address_list_content_item">
                <AddressCard/>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
@import "@/style/viriables.scss";
.address_list {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: $dark-bgColor;
    overflow-y: scroll;

    &_header {
        padding: .08rem .18rem;
        font-size: .16rem;
        color: $content-fontcolor;
        text-align: center;
        line-height: .24rem;
        background-color: $bgColor;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: space-between;
    }

    &_content {
        margin-top: .58rem;
    }
}
</style>